package com.huawei.fastengine.fastview.download.download;

import android.content.Context;
import com.huawei.fastengine.fastview.download.download.bean.DownloadRequest;

class DownloadManager$1 implements Runnable {
    final /* synthetic */ DownloadManager this$0;
    final /* synthetic */ Context val$context;
    final /* synthetic */ DownloadListener val$listener;
    final /* synthetic */ DownloadRequest val$request;

    DownloadManager$1(DownloadManager downloadManager, DownloadRequest downloadRequest, Context context, DownloadListener downloadListener) {
        this.this$0 = downloadManager;
        this.val$request = downloadRequest;
        this.val$context = context;
        this.val$listener = downloadListener;
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void run() {
        /*
        r12 = this;
        r10 = -1;
        r1 = 0;
        r5 = 0;
        r0 = "DownloadManager";
        r2 = "downloadAsync";
        com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils.e(r0, r2);
        r0 = r12.this$0;	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r2 = r12.val$request;	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r2 = r2.getUrl();	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r3 = r12.val$context;	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r2 = com.huawei.fastengine.fastview.download.download.DownloadManager.access$000(r0, r2, r3);	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r0 = r2.getResponseCode();	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r3 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        if (r0 == r3) goto L_0x0045;
    L_0x0020:
        r2 = "DownloadManager";
        r3 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r3.<init>();	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r4 = "server response code is not 200,code is ";
        r3 = r3.append(r4);	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r0 = r3.append(r0);	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r0 = r0.toString();	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils.e(r2, r0);	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r0 = r12.val$listener;	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r2 = 1;
        r0.failure(r2);	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r1);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r1);
    L_0x0044:
        return;
    L_0x0045:
        r0 = r12.val$request;	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r0 = r0.getSize();	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        if (r0 != r10) goto L_0x0104;
    L_0x004d:
        r3 = "Content-Length";
        r3 = r2.getHeaderField(r3);	 Catch:{ NumberFormatException -> 0x00fc }
        r0 = java.lang.Integer.parseInt(r3);	 Catch:{ NumberFormatException -> 0x00fc }
        r6 = r0;
    L_0x0058:
        r3 = r2.getInputStream();	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
        r2 = new java.io.File;	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r0 = r12.val$context;	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r0 = r0.getFilesDir();	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r4 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r4.<init>();	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r8 = java.lang.System.currentTimeMillis();	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r4 = r4.append(r8);	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r7 = ".apk";
        r4 = r4.append(r7);	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r4 = r4.toString();	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r2.<init>(r0, r4);	 Catch:{ IOException -> 0x01ac, all -> 0x019e }
        r4 = new java.io.FileOutputStream;	 Catch:{ IOException -> 0x01b1, all -> 0x019e }
        r4.<init>(r2);	 Catch:{ IOException -> 0x01b1, all -> 0x019e }
        r0 = 2048; // 0x800 float:2.87E-42 double:1.0118E-320;
        r7 = new byte[r0];	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r3.read(r7);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = "DownloadManager";
        r8 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r8.<init>();	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r9 = "isDownload";
        r8 = r8.append(r9);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r9 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r9 = com.huawei.fastengine.fastview.download.download.DownloadManager.access$100(r9);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r8 = r8.append(r9);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r8 = r8.toString();	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils.e(r1, r8);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = r5;
    L_0x00aa:
        if (r0 == r10) goto L_0x0107;
    L_0x00ac:
        r8 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r8 = com.huawei.fastengine.fastview.download.download.DownloadManager.access$100(r8);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        if (r8 == 0) goto L_0x0107;
    L_0x00b4:
        r8 = 0;
        r4.write(r7, r8, r0);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r3.read(r7);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r5 = r5 + r0;
        r1 = r1 + 1;
        r8 = r1 % 200;
        if (r8 == 0) goto L_0x00c5;
    L_0x00c3:
        if (r5 != r6) goto L_0x00aa;
    L_0x00c5:
        r8 = r12.val$listener;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r8.progress(r5, r6);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        goto L_0x00aa;
    L_0x00cb:
        r0 = move-exception;
        r1 = r2;
        r2 = r3;
        r3 = r4;
    L_0x00cf:
        r4 = "DownloadManager";
        r5 = new java.lang.StringBuilder;	 Catch:{ all -> 0x01a3 }
        r5.<init>();	 Catch:{ all -> 0x01a3 }
        r6 = "download error, error is ioexception";
        r5 = r5.append(r6);	 Catch:{ all -> 0x01a3 }
        r0 = r0.toString();	 Catch:{ all -> 0x01a3 }
        r0 = r5.append(r0);	 Catch:{ all -> 0x01a3 }
        r0 = r0.toString();	 Catch:{ all -> 0x01a3 }
        com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils.e(r4, r0);	 Catch:{ all -> 0x01a3 }
        com.huawei.fastengine.fastview.download.download.DownloadManager.deleteFile(r1);	 Catch:{ all -> 0x01a3 }
        r0 = r12.val$listener;	 Catch:{ all -> 0x01a3 }
        r1 = 3;
        r0.failure(r1);	 Catch:{ all -> 0x01a3 }
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r2);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r3);
        goto L_0x0044;
    L_0x00fc:
        r3 = move-exception;
        r3 = "DownloadManager";
        r4 = "get download content-length failure.";
        com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils.e(r3, r4);	 Catch:{ IOException -> 0x01a7, all -> 0x0194 }
    L_0x0104:
        r6 = r0;
        goto L_0x0058;
    L_0x0107:
        r0 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = com.huawei.fastengine.fastview.download.download.DownloadManager.access$100(r0);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        if (r0 != 0) goto L_0x0144;
    L_0x010f:
        r0 = "DownloadManager";
        r1 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1.<init>();	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r5 = "!isDownload";
        r1 = r1.append(r5);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r5 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r5 = com.huawei.fastengine.fastview.download.download.DownloadManager.access$100(r5);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = r1.append(r5);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = r1.toString();	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.utils.log.FastViewLogUtils.e(r0, r1);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.download.DownloadManager.deleteFile(r2);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r12.val$listener;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = 4;
        r0.failure(r1);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = 1;
        com.huawei.fastengine.fastview.download.download.DownloadManager.access$102(r0, r1);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r3);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r4);
        goto L_0x0044;
    L_0x0144:
        r0 = r12.val$listener;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0.progress(r6, r6);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r12.val$request;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r0.isNeedCheck();	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        if (r0 == 0) goto L_0x0182;
    L_0x0151:
        r0 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = r12.val$request;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = r1.getHash();	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = com.huawei.fastengine.fastview.download.download.DownloadManager.access$200(r0, r2, r1);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        if (r0 == 0) goto L_0x0171;
    L_0x015f:
        r0 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.download.DownloadManager.access$300(r0, r2);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r12.val$listener;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0.success(r2);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r3);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r4);
        goto L_0x0044;
    L_0x0171:
        com.huawei.fastengine.fastview.download.download.DownloadManager.deleteFile(r2);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r12.val$listener;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r1 = 2;
        r0.failure(r1);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r3);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r4);
        goto L_0x0044;
    L_0x0182:
        r0 = r12.this$0;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.download.DownloadManager.access$300(r0, r2);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0 = r12.val$listener;	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        r0.success(r2);	 Catch:{ IOException -> 0x00cb, all -> 0x01a1 }
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r3);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r4);
        goto L_0x0044;
    L_0x0194:
        r0 = move-exception;
        r3 = r1;
        r4 = r1;
    L_0x0197:
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r3);
        com.huawei.fastengine.fastview.download.utils.IoUtils.closeStream(r4);
        throw r0;
    L_0x019e:
        r0 = move-exception;
        r4 = r1;
        goto L_0x0197;
    L_0x01a1:
        r0 = move-exception;
        goto L_0x0197;
    L_0x01a3:
        r0 = move-exception;
        r4 = r3;
        r3 = r2;
        goto L_0x0197;
    L_0x01a7:
        r0 = move-exception;
        r2 = r1;
        r3 = r1;
        goto L_0x00cf;
    L_0x01ac:
        r0 = move-exception;
        r2 = r3;
        r3 = r1;
        goto L_0x00cf;
    L_0x01b1:
        r0 = move-exception;
        r11 = r2;
        r2 = r3;
        r3 = r1;
        r1 = r11;
        goto L_0x00cf;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.fastengine.fastview.download.download.DownloadManager$1.run():void");
    }
}
